import bge
#logic = bge.logic
#cont = logic.getCurrentController()
#own = cont.owner

#DATA HANDLING#
##############################################################
def propsToBGEdict():
    logic = bge.logic
    cont = logic.getCurrentController()
    own = cont.owner
    #print(dir(own))
    #print(own.name)
    if(len(own.getPropertyNames()) > 0):
        dict = {own.name:{}}
        
        for i in own.getPropertyNames():
            print(dict)
            print(i)
            dict[own.name][i] = own[i]
            
    #dict = {own.name : {own.getPropertyNames()}}
    #logic.GameDict = [own.name] = own.getPropertyNames()
    logic.globalDict.update(dict)
    
    # keep these until I can test some things
    #if(own.name in logic.globalDict.keys()):
        #logic.globalDict[own.name] = dict[own.name]
   # else:
        #logic.globalDict.update(dict)
        
    #logic.globalDict.update(dict)
    print(dir(logic.globalDict))
    print(logic.globalDict.keys())
    
def BGEdictToProps():
    logic = bge.logic
    cont = logic.getCurrentController()
    own = cont.owner
    #print(dir(own))
    #print(own.name)
    if(own.name in logic.globalDict.keys()):
        keys = logic.globalDict[own.name].keys()
        for i in keys():
            own[i] = logic.globalDict[own.name][i]
    else:
        print("It seems that the dictonary does not hold data for this object")


#END DATA HANDLING#
##############################################################


#OBLECT HANDLING#
##############################################################

# now at .50 

def parObjSelf(strObj):
    logic = bge.logic
    cont = logic.getCurrentController()
    own = cont.owner
    scene = logic.getCurrentScene()
    object = scene.addObject(strObj, own, 0)
    object.setParent(own)
    object.worldPosition = own.worldPosition
    object.orientation = own.orientation
    #print(dir(object))
    
def placeObj(strObj, vec3num, booself):
    logic = bge.logic
    cont = logic.getCurrentController()
    own = cont.owner
    scene = logic.getCurrentScene()
    if(booself):
        scene.addObject(strObj, own, 0)
    else:
        object = scene.addObject(strObj, strObj, 0)
        object.worldPosition = vec3num
    

#END OBLECT HANDLING#
##############################################################
